package com.mew.common.enm;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 0: 没有； 1，免费， 2， 特殊，3，jackpot【0:则修改最后一次押注金额，否则不修改】
 *
 * @author SK
 * @since 2019-08-13
 */
public enum SlotsWinType {

    None (0, "没有"),
    Free(1, "免费"),
    Special(2, "特殊"),
    Jackpot(3, "jackpot")
    ;

    private final static Map<Integer, SlotsWinType> stateMap
            = Arrays.stream(SlotsWinType.values()).collect(Collectors.toMap(SlotsWinType::code, code -> code));

    private final int code;
    private final String desc;

    /**
     * @param code 代码
     * @param desc 描述
     */
    private SlotsWinType(final int code, final String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int code() {
        return this.code;
    }

    public String desc() {
        return this.desc;
    }

    /**
     * @param code 代码
     * @return 转换出来的状态码
     */
    public static SlotsWinType parse(int code) {
        return stateMap.getOrDefault(code, SlotsWinType.None);
    }
}
